package com.sscaipiao.android.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.sscaipiao.android.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Airay.Rong on 14-1-22.
 */
public class JackpotItem extends LinearLayout {
	protected String mName;
	protected String mSeason;
	protected String mDate;

	private TextView mTVName;
	private TextView mTVSeason;
	private TextView mTVDate;

	private LinearLayout mContainer;


	public JackpotItem(Context context, AttributeSet attrs) {
		super(context, attrs);
		setOrientation(HORIZONTAL);
		TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.Jackpot);
		CharSequence temp = ta.getText(R.styleable.Jackpot_name);
		if (temp != null) {
			mName = temp.toString();
		}
		temp = ta.getText(R.styleable.Jackpot_season);
		if (temp != null) {
			mSeason = temp.toString();
		}
		temp = ta.getText(R.styleable.Jackpot_date);
		if (temp != null) {
			mDate = temp.toString();
		}
		ta.recycle();

		LayoutInflater li = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		li.inflate(R.layout.jackpotitem,this,true);

		mTVName = (TextView) findViewById(R.id.name);
		mTVSeason = (TextView) findViewById(R.id.season);
		mTVDate = (TextView) findViewById(R.id.date);
		mContainer = (LinearLayout) findViewById(R.id.container);
		setName(mName);
		setSeason(mSeason);
		setDate(mDate);
	}
	public void addContainerMain(int container_id) {
		LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View layout = inflater.inflate(container_id,null);
		if (layout != null) {
			mContainer.addView(layout);
		}
	}

	public void setName(String name) {
		if (name != null) {
			mTVName.setText(name);
		}
	}
	public String  getName() {
		return  mTVName.getText().toString();
	}
	public void setSeason(String season) {
		if (season != null) {
			mTVSeason.setText(season);
		}
	}

	public void setDate(String date) {
		if (date != null) {
			mTVDate.setText(date);
		}
	}
}
